import request from "@/utils/request";

// 调用注册用户接口
export function registerApi(data) {
  return request({
    url: "/register",
    method: "post",
    data,
  });
}

// 调用登录接口
export function loginApi(data) {
  return request({
    url: "/login",
    method: "post",
    data,
  });
}
// 调用登出接口
export function logoutApi(data) {
  return request({
    url: "/logout",
    method: "post",
    data,
    keepalive: true,
  });
}
// 获取登录验证码图片-base64
export function getCaptchaImageApi() {
  return request({
    url: "/captchaImage",
    method: "get",
    // GET请求无参数时可以省略params
  });
}

// 登录找回
export function passWordApi(data) {
  return request({
    url: "/password",
    method: "put",
    data,
  });
}
// 修改密码
export function userPassWordApi(data) {
  return request({
    url: "/me/password",
    method: "put",
    data,
  });
}
// 更新当前用户
export function systemUserIdApi(data) {
  return request({
    url: "/system/users/me",
    method: "put",
    data,
  });
}

// 获取当前用户-获取用户信息
export function systemUsersMeApi() {
  return request({
    url: "/system/users/me",
    method: "get",
  });
}

// 登录页公告
export function noticesListLimitApi() {
  return request({
    url: "/notices?isEffective=1&isPublished=1",
    method: "get",
  });
}
// 公告计数
export function noticesListLimitCountApi() {
  return request({
    url: "/notices/count",
    method: "get",
  });
}
// 获取主页
export function noticesListLimitHomeApi(params) {
  return request({
    url: "/notices",
    method: "get",
    params,
  });
}
// 获取公告详情
export function noticesListIdApi(id) {
  return request({
    url: "/notices/" + id,
    method: "get",
  });
}
// 公告-下载附件
export function noticesDownLoadApi(params) {
  return request({
    url: "/notices/download",
    method: "get",
    params,
  });
}
// 获取订阅的类型列表
export function noticesTypesSubscribleApi() {
  return request({
    url: "/types/subscribe",
    method: "get",
  });
}
// 获取登录用户的订阅列表
export function subscriptionsMeApi(params) {
  return request({
    url: "/subscriptions/me",
    method: "get",
    params,
  });
}
// 续订
export function subscriptionsIdResubscribleApi(id, data) {
  return request({
    url: "/subscriptions/" + id + "/resubscribe",
    method: "put",
    data,
  });
}
// 退订
export function subscriptionsIdUnscribleApi(id, data) {
  return request({
    url: "/subscriptions/" + id + "/unsubscribe",
    method: "put",
    data,
  });
}
// 忘记密码
export function meForgetPasswordApi(data) {
  return request({
    url: "/me/forget-password",
    method: "post",
    data,
  });
}
